package main

import (
	"context"
	"simcard/assistant"
	"simcard/auth"
	"simcard/bll"
	"simcard/client"
	"simcard/collector"
	log "simcard/collector/logger"
	"simcard/config"
	"simcard/event"
	"simcard/server"
	"simcard/store"
)

type InitFunc func() func()

func main() {
	var (
		// system init func
		bootstraps = []InitFunc{
			config.Init,
			collector.Init,
			auth.Init,
			server.Init,
			client.Init,
			store.Init,
			assistant.Init,
			bll.Init,
		}
	)

	event.Init()
	for _, bootstrap := range bootstraps {
		cancel := bootstrap()
		event.Subscribe(event.EventExit, func(ctx context.Context, e event.Event, payload interface{}) {
			cancel()
		})
	}

	log.Info("finished to init all component")
	config.MicroService.Run()
}
